<template>
  <div class="m-hearder">
      <div class="el-icon-arrow-left" @click="$router.go(-1)" v-if="goBackShow"></div>
      <div class="tit">{{msg}}</div>
  </div>
</template>

<script>
export default {
  name: 'Hearder',
  data () {
    return {
      msg: '数字星球商城',
      goBackShow:true
    }
  },
  created(){
    let vm = this
    if(vm.$route.path == '/' || vm.$route.path == '/category' || vm.$route.path == '/shoppingcar' || vm.$route.path == '/user'){
        vm.goBackShow = false
    }else{
        vm.goBackShow = true
    }
  },
  watch:{
    $route (val){
      let vm = this
      if(val.path == '/' || val.path == '/category' || val.path == '/shoppingcar' || val.path == '/user'){
        vm.goBackShow = false
      }else{
        vm.goBackShow = true
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
    .m-hearder{
      height: 2rem;
      line-height: 2rem;
    }
    .el-icon-arrow-left{
        float: left;
        line-height: 2rem;
    }
    .tit{
        text-align: center;
    }
</style>
